package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Course;
import cn.wolfcode.crm.mapper.CourseMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ICourseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CourseServiceImpl implements ICourseService {
    @Autowired
    private CourseMapper courseMapper;
    @Override
    public void update(Course course) {
        courseMapper.updateById(course);
    }

    @Override
    public void delete(Long id) {
        courseMapper.deleteById(id);
    }

    @Override
    public void insert(Course course) {
        courseMapper.insert(course);
    }

    @Override
    public Course select(Long id) {
        Course course = courseMapper.selectById(id);
        return course;
    }

    @Override
    public List<Course> selectAll() {
        List<Course> list = courseMapper.selectAll();
        return list;
    }

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        //查询结果集
        List<Course> list = courseMapper.selectForList(qo);
        return new PageInfo(list);
    }
}
